<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="zh-CN">
    <meta content="1 days" name="revisit-after" />
    <meta name="robots" content="all">
    <meta name="viewport" content="width=750, maximum-scale=1.0, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <meta content="false" id="twcClient" name="twcClient" />
    <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5)" />
    <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5)" />
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/get.css">
    <script src="js/common.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>领取亮度</title>
</head>

<body>
    <div class="get" id="get" @touchmove.prevent>
        <div class="main">
            <div class="rules_txt" @click.stop='showRule'>
            </div>                                                
        </div>
        <div class="bottom">
            <div @click.stop='getInto'>点击领取</div>
        </div>
        <transition name="slide-fade">
            <div class="rule" v-if="ruleShow" @click.stop='close' @touchmove.prevent></div>
        </transition>
        <transition name="slide-fade">
            <div class="code" v-if="codeShow" @touchmove.prevent>
                <img :src="qrImg" alt="">
            </div>
        </transition>
    </div>
</body>

</html>
<script>
    var app4 = new Vue({
        el: '#get',
        data() {
            return {
                ruleShow: false,
                codeShow: false,
                shareCode: '',
                SetFun:'',
                partner :'',
                qrImg:''
            };
        },
        methods: {
            showRule() {
                this.ruleShow = true;
                document.documentElement.scrollTop = document.body.scrollTop = 0;
            },
            close() {
                this.ruleShow = false;

            },
            getInto() {
                
                this.SetFun.isCode(this.qrCode); 
                document.documentElement.scrollTop = document.body.scrollTop = 0;
            },
            getParam(paramName) {
                paramValue = "", isFound = !1;
                if (window.location.search.indexOf("?") == 0 && window.location.search.indexOf("=") > 1) {
                    arrSource = unescape(window.location.search).substring(1, window.location.search.length).split("&"), i = 0;
                    while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
                }
                return paramValue == "" && (paramValue = null), paramValue
            },
            qrCode(){
                var _self = this;
                var access_token = localStorage.getItem('access_token');
                var shareCode = localStorage.getItem('shareCode');
                axios.get('http://airen.2020-2020.com/v1/invites/'+shareCode+'?access_token=' + access_token)
                    .then(function(response){
                        _self.codeShow = true;
                        _self.partner = response.data.data;
                        // document.title = '领取“'+_self.partner.inviter.name+'”送您的亮度';
                        _self.qrImg = 'http://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='+response.data.data.qr.ticket;
                    })
            },
        },
        created() {
             var shareCode = this.getParam('shareCode');
             localStorage.setItem('shareCode',shareCode);
        },
        mounted() {
            var _self = this;
            _self.SetFun = new window.SetFun();
            var recode = _self.SetFun.getParam('redirectcode');
             if(recode){
                _self.getInto();
             }
            _self.SetFun.hideMenu();
        },
    })
</script>